<?php

namespace app\command;

use app\shop\model\MeetingModel;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Meeting extends Command
{
    protected function configure()
    {
        $this->setName('Meeting')->setDescription('Here is the remark ');
    }

    protected function execute(Input $input, Output $output)
    {
        $list =MeetingModel::where('status','in',[0,1])->select()->toArray();
        foreach ($list as $value){
            if($value['status']==0){
                if(time()>=$value['start_time']){
                    MeetingModel::where('id',$value['id'])->update(['status'=>1]);
                    echo $value['meeting_name'] ."->开始".PHP_EOL;
                }
            }else{
                if(time()>=$value['end_time']){
                    MeetingModel::where('id',$value['id'])->update(['status'=>2]);
                    echo $value['meeting_name'] ."->活动结束".PHP_EOL;
                }
            }
        }
    }
}